/*
 * Copyright 2010 J Patrick Davenport
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package v4view.core.utils;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

import java.util.Locale;

import org.junit.Test;

public class ResourceManagerTests {
	final ResourceManager	resource	= ResourceManager.getManager();

	@Test
	public void checkResourceLoading() {
		final String defaultLang = System.getProperty("user.language");
		System.out.println("System language: " + defaultLang);
		final String value = this.resource.getValue("v4view.web.ext.test", "location", new Locale(defaultLang));
		assertEquals("A rocking house.", value);

		final String frenchValue = this.resource.getValue("v4view.web.ext.test", "location", new Locale("fr"));
		assertEquals("A rocking house, wee wee.", frenchValue);
	}

	@Test
	public void checkLoadExistingFile() {

		final String loadFileContent = this.resource.loadFileContent("/HomeScript.js");
		assertNotNull(loadFileContent);
		assertEquals("function hello(){\r\n" +
				"	alert(\"Hello, World!\");\r\n" +
				"}", loadFileContent);
	}

	@Test
	public void checkLoadAgain() {
		this.checkLoadExistingFile();
		assertTrue(this.resource.containsFile("/HomeScript.js"));
	}
}
